//
//  main.c
//  intmap
//
//  Created by liwei on 13-11-10.
//  Copyright (c) 2013年 liwei. All rights reserved.
//

#include <stdio.h>
#include "astar.h"
#include "astarcpp.h"
#include <list>

int main(int argc, const char * argv[])
{

    // insert code here...
//    printf("Hello, World!\n");
//    char data[5][5] =
//    {
//        {0,0,0,0,0},
//        {1,1,1,1,1},
//        {1,0,0,0,1},
//        {1,0,0,0,1},
//        {1,1,1,1,1}
//    };
//    VALUE origin = {1,0};
//    VALUE target = {0,4};
//    find_path((VALUE *)data, origin, target);

    //A*寻路算法调用
    //
    // 起始点与终点
    //
    start = { 4, 8 };
    endp = { 13, 6 };
    TILE * bestnode = FindPath(start.x, start.y, endp.x, endp.y);
    int len = bestnode->f;
    printf("bestnode:%d %d\n", bestnode->x, bestnode->y);
    for (int i = 0; i < len; ++i) {
        map[bestnode->father->y][bestnode->father->x] = '^';
        bestnode = bestnode->father;
    }
//    std::list< TILE * >::iterator i = open_list.begin();
//    while (i != open_list.end())
//    {
//        printf("%d %d %d %d %d\n", (*i)->x, (*i)->y, (*i)->f, (*i)->g, (*i)->h);
//    }
//    return 0;
    
//    char bdata[8] = {0};
//    bdata[0] = 0b10101010;
//    printf("%o\n",bdata[0]);
//    //地图表示法
    printf("%s\n", (char *)map[0]);
    printf("%s\n", (char *)map[1]);
    printf("%s\n", (char *)map[2]);
    printf("%s\n", (char *)map[3]);
    printf("%s\n", (char *)map[4]);
    printf("%s\n", (char *)map[5]);
    printf("%s\n", (char *)map[6]);
    printf("%s\n", (char *)map[7]);
    printf("%s\n", (char *)map[8]);
    printf("%s\n", (char *)map[9]);
    printf("%s\n", (char *)map[10]);
    printf("%s\n", (char *)map[11]);
    printf("%s\n", (char *)map[12]);
    printf("%s\n", (char *)map[13]);
    printf("%s\n", (char *)map[14]);
    printf("%s\n", (char *)map[15]);
}

